<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .div1>.p1 {
            color: red;
        }

        .div2>.p1 {
            color: blue;
        }
    </style>
</head>
<body>
    <!-- id="fengxian-center-div1" -->
    <div class="div1" id="div1">
        <p class="p1">div1-p1</p>
        <p class="p1">div1-p2</p>
        <p class="p1">div1-p3</p>
    </div>
    <div class="div2" id="div2">
        <p class="p1">div2-p1</p>
        <p class="p1">div2-p2</p>
        <p class="p1">div2-p3</p>
    </div>
    <button onclick="handleClick()">点击我</button>
</body>
<script>

    function handleClick() {
        // 查找所有匹配的DOM对象，返回数组
        let a = document.querySelectorAll(".div1>.p1")
        for (let v of a) {
            console.log(v.innerHTML);
        }

        // 查找匹配的第一个DOM对象，返回对象
        console.log("---------------分隔符------------------")
        a = document.querySelector(".div1>.p1")
        console.log(a.innerHTML);
    }
</script>
</html>